#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>


  BYTE *Vga = (BYTE *)0xA0000000;
  BYTE vbuffer[0xFFFF];

  int  x,
       y,
       data;

  void Screen( BYTE mode );

  FILE *df;

//--------------------//
//                    //
//--------------------//
int  main( )
{
  Screen( 0x13 );

  randomize( );

  // Color #0
  memset( vbuffer, 0, 0xFFFF );
  // Color #2
  for ( y = 0; y < 64; y++ )
  {
    for ( x = 0; x < 256; x++ )
      vbuffer[ (y * 320) + x ] = 2;
  }
  // Color #3
  for ( data = 0; data < (64 * 256); data++ )
  {
    x = rand( ) % 256;
    y = rand( ) % 64;
    //
    vbuffer[ (y * 320) + x ] = 3;
  }
  // Color #1
  for ( data = 0; data < (32 * 256); data++ )
  {
    x = rand( ) % 256;
    y = rand( ) % 64;
    //
    vbuffer[ (y * 320) + x ] = 1;
  }

  // Transfer to thescreen
  memcpy( Vga, vbuffer, (320*200) );

  df = fopen( "c:/romhack/trans/dm/title/title.col", "wb" );
  if ( df )
	{
    for ( y = 0; y < 64; y++ )
     fwrite( &vbuffer[ y * 320 ], 1, 256, df );
    //
    fclose( df );
	}


  while( !kbhit( ) )
	{
    data++;
  }

  Screen( 0x00 );

  return 0;
}


//--------------------//
//                    //
//--------------------//
void Screen( BYTE mode )
{
  asm {
    mov ah, 0
    mov al, [mode]
    int 0x10
  }
}